package com.chen.auth.handler;

import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpHeaders;
import org.springframework.scheduling.annotation.Async;
import org.springframework.security.core.Authentication;
import org.springframework.security.oauth2.provider.OAuth2Authentication;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * oauth2.0登出处理器
 *
 * @author shenghua
 * @date 2021/06/22
 */
@Slf4j
@Component
@AllArgsConstructor
public class AuthenticationLogoutEventHandler{

	/**
	 * 处理登录成出方法
	 */
	@Async
	public void handle(Authentication authentication, HttpServletRequest request, HttpServletResponse response) {
		log.info("用户： {} 退出成功, token: {} -> 已注销",authentication.getName(),request.getHeader(HttpHeaders.AUTHORIZATION));
	}

}
